package c.j.a.c.g$i;

import android.os.Environment;
import c.j.a.b.a.c.a;
import c.j.a.c.g$g.d;
import c.j.a.c.g.y;
import c.j.a.d.b.e.i;
import com.ss.android.socialbase.downloader.g.c;
import java.io.File;
import org.json.JSONException;
import org.json.JSONObject;

/* compiled from: CleanSpaceTask */
public class b implements Runnable {
    public c a;

    public b(c cVar) {
        this.a = cVar;
    }

    public void run() {
        c.j.a.c.o.b bVar = c.j.a.c.o.b.b.a;
        c cVar = this.a;
        if (cVar != null) {
            a b = d.c.a.b(cVar);
            if (b != null) {
                bVar.i("cleanspace_task", b);
                File externalStorageDirectory = Environment.getExternalStorageDirectory();
                long longValue = Double.valueOf((c.j.a.d.b.l.a.d(this.a.g0()).a("clean_min_install_size", 0.0d) + 1.0d) * ((double) this.a.T)).longValue() - this.a.I();
                c.h.a.m0.r.a.g();
                c.h.a.m0.r.a.q();
                int i = 0;
                if ((c.j.a.d.b.l.a.d(b.q).b("clean_app_cache_dir", 0) == 1 ? 1 : null) != null) {
                    c.h.a.m0.r.a.h(y.a());
                }
                long j = 0;
                try {
                    j = c.j.a.d.b.n.a.J(externalStorageDirectory.toString());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (j >= longValue) {
                    i = 1;
                }
                b.I = true;
                if (i != 0) {
                    b.H = "1";
                    c.j.a.c.g$g.g.b.a.a(b);
                    bVar.i("cleanspace_download_after_quite_clean", b);
                    i.a(y.a()).j(this.a.g0());
                } else {
                    JSONObject jSONObject = new JSONObject();
                    try {
                        jSONObject.putOpt("show_dialog_result", Integer.valueOf(3));
                    } catch (JSONException e2) {
                        e2.printStackTrace();
                    }
                    bVar.n("cleanspace_window_show", jSONObject, b);
                }
            }
        }
    }
}
